<?php
/**
 * 
 * Enter description here ...
 * @author 4-PC
 *
 */
 
class SiteController extends Controller
{
	public $defaultAction = 'index';
	public $layout="main";
	protected $_identity;
 	public $_logouturl;
	public $background_image;
 	
	public function actions()
	{
		return array(
			// captcha action renders the CAPTCHA image displayed on the contact page
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
			),
			// page action renders "static" pages stored under 'protected/views/site/pages'
			// They can be accessed via: index.php?r=site/page&view=FileName
			'page'=>array(
				'class'=>'CViewAction',
			),
		);
	}

	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{		
		$this->render('index') ;
	}
        
       public function actionLogin()
	{
		$model = new LoginForm;
		    // if (!empty(Yii::app()->session['user_name']))
  				// $this->redirect(ApplicationConfig::getURL('', 'site', 'index'));
				
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
//                    var_dump($_POST['LoginForm']);exit;
			$model->attributes=$_POST['LoginForm'];
			
			// validate user input and redirect to the previous page if valid
			if($model->validate()){						 
				$this->redirect(ApplicationConfig::getURL('', 'site', 'index'));
			}
			else{
			$errors = CHtml::errorSummary($model);
				
			}	
		}
		// display the login form
		$this->render('Loginpop',array('model'=>$model,'error'=>$errors));
	}
	
        public function actionArticle()
        {
            $this->render('article') ;
        }
	
	public function actionVideo()
        {
            $this->render('Vedio') ;
        }
	public function actionForum()
        {
            $this->render('forumlist');
        }       
	
	public function actionExperts()
        {
            $this->render('expertslist') ;
        }
	public function actionJudiciary()
        {
            $this->render('judiciary') ;
        }
	public function actionTestSeries()
        {
            $this->render('testseries') ;
        }
        public function actionTestSeriesNext()
        {
            $this->render('testseries1') ;
        }
  	public function actionError()
	{
    
	    if($error=Yii::app()->errorHandler->error)
	    {
	    	if(Yii::app()->request->isAjaxRequest)
	    		echo $error['message'];
	    	else
	        	$this->render('error', $error);
	    }
	}
        public function actionLoginpop()
        {
            $this->layout = 'ajax_layout';
            $model = new LoginForm;
		    // if (!empty(Yii::app()->session['user_name']))
  				// $this->redirect(ApplicationConfig::getURL('', 'site', 'index'));
				
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			
			// validate user input and redirect to the previous page if valid
			if($model->validate()){						 
				$this->redirect(ApplicationConfig::getURL('', 'site', 'index'));
			}
			else{
			$errors = CHtml::errorSummary($model);
				
			}	
		}
		// display the login form
		$this->render('Loginpop',array('model'=>$model,'error'=>$errors));
        }        
}       
    